import request from '@/utils/request'
import qs from 'qs'

export function initData(url, params, type) {
  if (type && type === 'post') {
    return request.post(url, params).then((res) => {
      return res.data
    })
  } else {
    return request({
      url: url + '?' + qs.stringify(params, {indices: false}),
      method: 'get'
    }).then((res) => {
      return res.data
    })
  }
}

export function download(url, params) {
  return request({
    url: url + '?' + qs.stringify(params, {indices: false}),
    method: 'get',
    responseType: 'blob'
  })
}
